package com.maosy.demo

import android.app.Application
import com.maosy.demo.api.HttpRequest
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.embedding.engine.FlutterEngineCache
import io.flutter.embedding.engine.dart.DartExecutor
import java.io.Serializable

class MyApp : Application() {

    lateinit var flutterEngine: FlutterEngine

    override fun onCreate() {

        // 初始化HTTP API请求
        HttpRequest.init()
        // flutter 引擎预热
        flutterEngine = FlutterEngine(applicationContext)
        flutterEngine.dartExecutor.executeDartEntrypoint(
            DartExecutor.DartEntrypoint.createDefault()
        )
        FlutterEngineCache
            .getInstance()
            .put(MyFlutterActivity.CACHED_ENGINE_ID, flutterEngine)
        super.onCreate()
    }

    companion object {
        var location: Location? = null
    }
}

data class Location(
    var latitude: Double = 0.0,
    var longitude: Double = 0.0
) : Serializable {

}